﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.Collections;

namespace project3
{
    class ViewGroup : View
    {
        // Fields
        private ArrayList children = new ArrayList();

        // Constructors
        public ViewGroup(string name) : base(name) { }


        // Methods for managing--分支节点专有的方法
        public void Add(View view)
        {
            children.Add(view);
        }
        public void Remove(View view)
        {
            children.Remove(view);
        }


        public override void Display(int depth)
        {
            Console.WriteLine(new String('-', depth) + name);

            // Display each of the node's children
            foreach (View view in children)
                view.Display(depth + 2);
        }
    }
}
